package com.butuh.uang.tuh.ang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.butuh.uang.tuh.ang.R;
import com.butuh.uang.tuh.ang.model.HomeListBean;
import com.butuh.uang.tuh.ang.util.DecimalFormatUtil;

import cn.droidlover.xdroidmvp.base.XListAdapter;

public class HomeListEasyAdapter extends XListAdapter<HomeListBean> {

    public HomeListEasyAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHloder viewHloder;
        if (convertView == null) {
            viewHloder = new ViewHloder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_home_easy_list, null);
            viewHloder.iv_product_logo = convertView.findViewById(R.id.iv_product_logo);
            viewHloder.tv_product_name = convertView.findViewById(R.id.tv_product_name);
            viewHloder.tv_product_money = convertView.findViewById(R.id.tv_product_money);
            viewHloder.tv_product_bunga = convertView.findViewById(R.id.tv_product_bunga);
            convertView.setTag(viewHloder);
        } else {
            viewHloder = (ViewHloder) convertView.getTag();
        }
        HomeListBean bean = data.get(position);
        Glide.with(context).load(bean.getIdentification()).into(viewHloder.iv_product_logo);
        viewHloder.tv_product_name.setText(bean.getDesignation());
        viewHloder.tv_product_money.setText("Rp "+ DecimalFormatUtil.formatNumberWithMarkSplit(bean.getShowLargestAmountOfMoney(),0));
        viewHloder.tv_product_bunga.setText(Double.parseDouble(bean.getDisplayTheLoanPeriod())*100+"%/Hari");

        return convertView;
    }

    class ViewHloder {
        ImageView iv_product_logo;
        TextView tv_product_name;
        TextView tv_product_money;
        TextView tv_product_bunga;
    }

}
